package Exercise1;

import java.util.*;

public class MapTest {
    public static void main(String args[])
    {
        Map<Integer,Students> map = new HashMap<>();
        Students t1 = new Students("石文学",18,"男",98.3);
        Students t2 = new Students("刘德华",65,"男",253.3);
        Students t3 = new Students("张学友",59,"男",78.5);
        Students t4 = new Students("汉堡",12,"男",15.8);
        map.put(1001,t1);
        map.put(1002,t2);
        map.put(1003,t3);
        map.put(1004,t4);
        map.put(1005,new Students("奥特曼",19,"女",58.5));
//        System.out.println(map.get(1001));

        //map.remove(1004);
        //map.put(1002,new Students("高斯林",56,"男",987.2));
//        Students s1 = map.get(1005);
//        System.out.println(s1);
//        System.out.println(map.size());
//        Set<Integer> k1 = map.keySet();
//        Iterator<Integer> iterator1 = k1.iterator();
//        while (iterator1.hasNext())
//        {
//            System.out.println(iterator1.next());
//        }
        Collection<Students> values = map.values();
        Iterator<Students> iterator = values.iterator();
        while (iterator.hasNext())
        {
            System.out.println(iterator.next());
        }
//        Set<Integer> key = map.keySet();
//        Iterator<Integer> iterator = key.iterator();
//        while (iterator.hasNext())
//        {
//            Integer next = iterator.next();
//            Students students = map.get(next);
//            System.out.println(next+"======"+students);
//        }
        Set<Integer> integers = map.keySet();
        Iterator<Integer> iterator1 = integers.iterator();
        while (iterator1.hasNext())
        {
            Integer next = iterator1.next();
            Students students = map.get(next);
            System.out.println(next + "====="+students);
        }
    }
}
